// pages/h_card/index.js
import {Base} from'../../utils/base.js';
import {Model} from './model.js'
const model=new Model();
var base =new Base();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    cardBg:'',
    userInfo:{},
    subUserCount:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    model.getSubUser((res)=>{
      this.setData({
        subUserCount:res.data.length
      })
    })

    this.getResquest((res)=>{
      this.setData({
        cardBg:res.data.h_card.img
      })
    });

    model.getUserInfo((res)=>{
      this.setData({
        userInfo:res.data.data
      })
    })
  },

  getResquest(callback){
    base.request({
      url: '/h_card_request',
      success: function (res) {
        callback(res);
      }
    });
  },

  // 分享海报
  onShareImage(){
    wx.navigateTo({
      url: '../h_card_share/index',
    })
  }
})